﻿#pragma once


#define _CRT_SECURE_NO_WARNINGS 1

#define PANEL_COLS 87
#define PANEL_ROWS 36
#define SNAKELONG  4
#define POS_X      10
#define POS_Y      6
#define SLEEPTIME  140
#define SKILLTIME  10

#define HONKAI_SKILL "崩"
#define BEFALL_SKILL "坏"
#define BOOY         "原"
#define FOOD         "神"

#define KEY_PRESS(VK) ((GetAsyncKeyState(VK)&0x1) ? 1 : 0)

//#include<unistd.h>
#include<stdio.h>
#include<Windows.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<locale.h>
#include<assert.h>


enum DIRECTION
{
	UP = 1,
	DOWN,
	LEFT,
	RIGHT
};

enum GAME_STATUS
{
	OK,
	END_NORNAL,
	KILL_BY_WALL,
	KILL_BY_SELF
};

typedef struct SnakeNode
{
	int x;
	int y;
	struct SnakeNode* next;
}SnakeNode, * pSnakeNode;

typedef struct Snake
{
	pSnakeNode _pSnake;
	pSnakeNode _pFood;
	int _score;
	int _FoodWeight;
	enum DIRECTION _Dir;
	enum GAME_STATUS _Status;
	int SleepTime;
}Snake, * pSnake;

void PanelDevise(void);//设置标题名称，

void HideCursor(void);//设置光标状态

void Setpos(int x, int y);//设置光标输出位置

void induct(void);//游戏引导界面

pSnake SnakeMakeNode(int x, int y);//生成蛇的节点

void InitSnake(pSnake ps);//初始化蛇

void CreateFood(pSnake ps);//放置食物

void pause(void);//暂停（以SPACE键为开始）

int NextIsFood(pSnakeNode psn, pSnake ps);//判断前方是否有食物

void EatFood(pSnakeNode psn, pSnake ps);//吃到食物的处理方案

void NoFood(pSnakeNode psn, pSnake ps);//没有食物的处理方案

int KillByWall(pSnake ps);//撞墙死亡

int KillBySelf(pSnake ps);//自己吃到自己死亡

void SnakeMove(pSnake ps);//蛇的移动

void GameState(pSnake ps);//开始游戏

void GameRun(pSnake ps);//运行游戏

void GameEnd(pSnake ps);//游戏结束

//😄😋